package org.argetr.resim.proc.filter;
import javax.media.jai.JAI;
import javax.media.jai.KernelJAI;
import javax.media.jai.PlanarImage;

import org.argetr.resim.proc.data.*;



public class ConvolutionPR extends SpatialPR {
    protected KernelDA _kernel = new KernelDA(new float[][]{ {0, 0, 0},
    		                                                 {0, 1, 0},
    		                                                 {0, 0, 0}
    		                                               }
                                             );
	public void setParameters(KernelDA kernel){
		setParamKernel(kernel);
	}
	public void setParamKernel(KernelDA kernel){
		_kernel = kernel;
	}
	public KernelDA getParamKernel(){
		return _kernel;
	}
	public Data process() {
		KernelDA kernel = getParamKernel();
		KernelJAI kernelJAI = new KernelJAI(kernel.getNCol(),
				kernel.getNCol(), ConverterUT.get1DFloatArray(kernel.getKernel()));
		PlanarImage i = getInputAsPlanarImage();
		PlanarImage o = JAI.create("convolve", i, kernelJAI);
		ImageDA out = new ImageDA(o);
		setOutput((Data)out);	
		return getOutput();
	}
}
